package com.niu.test;

import java.util.Random;

public class Student {
    public static void main(String[] args) {
        //记录每个学生的的票数
        int[] student = new int[10];
        Random random = new Random();
        //记录每个学生的投票状态  是/否
        boolean[] vote = new boolean[10];
        //表示学生的姓名
        String[] name = new String[]{"a","b","c","d","e","f","g","h","i","g"};
        //记录总的投票人数
        int count = 0;
        for (int i = 0; i < name.length-1; i++) {
            if (!vote[random.nextInt(10)]){
                vote[random.nextInt(10)] = true;
                random = new Random();
                student[random.nextInt(10)] +=1;
                count++;
            }
        }
        System.out.println("投票人数是：" + count);
        for (int i = 0; i < 10; i++) {
            System.out.println(name[i] + "的的票数为" + student[i]);
        }
    }
}
